import { queryOuterFiles, addOuterFiles,removeOuterFiles,updateOuterFiles,connectTest,queryUnicodeList} from '@/services/bnsConfig/outerFiles';

export default {
  namespace: 'outerFiles',

  state: {
    // 列表数据
    data: {
      dataList: [],
      pageNum: 0,
      pageSize: 0,
      totalCount: 0,
    },

    queryForm:{},

  },

  effects: {
    *queryList({ payload }, { call, put }) {
      const response = yield call(queryOuterFiles, payload);
      yield put({
        type: 'save',
        payload: response,
      });
    },
    *add({ payload, callback }, { call, put }) {
      const response = yield call(addOuterFiles, payload);
      yield put({
        type: 'saveadd',
        payload: response,
      });
      if (callback) callback(response);
    },
    *remove({ payload, callback }, { call, put }) {
      const response = yield call(removeOuterFiles, payload);
      yield put({
        type: 'saveremove',
        payload: response,
      });
      if (callback) callback(response);
    },
    *update({ payload, callback }, { call, put }) {
      const response = yield call(updateOuterFiles, payload);
      yield put({
        type: 'saveupdate',
        payload: response,
      });
      if (callback) callback(response);
    },

    * unicodeList({payload, callback}, {call, put}) {
      const response = yield call(queryUnicodeList, payload);
      yield put({
        type: 'saveunicodeList',
        payload: response,
      });
      if (callback) callback(response);
    },

    *test({ payload, callback }, { call, put }) {
      const response = yield call(connectTest, payload);
      yield put({
        type: 'savetest',
        payload: response,
      });
      if (callback) callback(response);
    },
  },

  reducers: {
    save(state, action) {
      return {
        ...state,
        data: action.payload.data||{},
      };
    },
  },
};
